﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using KeRui.Common;
using System.Text;

public partial class Manage_Seller_GetAdCode : System.Web.UI.Page
{
    protected KeRui.Model.Ad modelAd = new KeRui.Model.Ad();
    protected KeRui.BLL.Ad bllAd = new KeRui.BLL.Ad();
    private ManageErrMsg nsb = new ManageErrMsg();
    protected void Page_Load(object sender, EventArgs e)
    {
        ManageHelper.CheckAdminLogin();//登陆判断
        int ID = PageRequest.GetInt("ID", -1);
        if (ID == -1)
        {
            nsb.AddErr("非法访问。"); nsb.ChkErr();
        }
        modelAd = bllAd.GetModel(ID);
        if (modelAd == null)
        {
            nsb.AddErr("对不起！您要访问的信息不存在。"); nsb.ChkErr();
        }
    }
    protected string GetCodeInclude()
    {
        StringBuilder RetStr = new StringBuilder();
        //RetStr.Append("<script src=\"/Aspx/GetAd.aspx?id=" + modelAd.AdID + "\"></script>");<span id="adv2"></span><script>ajaxAdv("adv2",25)</script>
        RetStr.AppendFormat("<span id=\"span{0}\"><!--#include file=\"/Template/_ad/{0}.shtml\"--></span>", modelAd.AdID);
        return RetStr.ToString();
    }

    protected string GetCodeJS()
    {
        int siteID = PageRequest.GetInt("siteID", -1);

        if (siteID > 0)
        {
            KeRui.BLL.CmsSite bllCmsSite = new KeRui.BLL.CmsSite();
            KeRui.Model.CmsSite modelCmsSite = bllCmsSite.GetModelByCache(siteID);
            string SiteUrl = modelCmsSite.SiteUrl;

            StringBuilder RetStr = new StringBuilder();
            RetStr.AppendFormat("<script type=\"text/javascript\" src=\"{0}/Template/_ad/{1}.js\"></script>", SiteUrl, modelAd.AdID);
            return RetStr.ToString();
        }
        else
        {
            return "";
        }
    }
}
